/* $Id: MapMouseListener.java 60 2010-02-01 19:54:35Z aaron.day $ */
package org.crazydays.gameplan.map.swing;


import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

/**
 * MapMouseListener
 */
public class MapMouseListener
    extends MouseAdapter
{
    /** menu */
    protected JMapContextMenu contextMenu;

    /**
     * Set context menu.
     * 
     * @param contextMenu Context menu
     */
    public void setContextMenu(JMapContextMenu contextMenu)
    {
        this.contextMenu = contextMenu;
    }

    /**
     * Show context menu on right mouse click.
     * 
     * @param event Event
     * @see MouseAdapter#mousePressed(MouseEvent)
     */
    @Override
    public void mousePressed(MouseEvent event)
    {
        // right button opens context menu
        if (event.getButton() == MouseEvent.BUTTON3) {
            contextMenu.show(event.getComponent(), event.getX(), event.getY());
        }
    }
}
